package com.example.campuslink.ui.activity.ai

import androidx.recyclerview.widget.LinearLayoutManager
import com.example.campuslink.BR
import com.example.campuslink.R
import com.example.campuslink.commen.adpter.AiHistoryAdapter
import com.example.campuslink.commen.tools.SpacesItemButtonDecoration
import com.example.campuslink.databinding.ActivityAiHistoryBinding
import com.example.campuslink.ui.activity.BaseActivity
import com.example.campuslink.viewModel.ai.InquiriesViewModel

class AiHistoryActivity : BaseActivity<ActivityAiHistoryBinding, InquiriesViewModel>(
    InquiriesViewModel::class.java,
    R.layout.activity_ai_history,
    BR.viewModel
) {
    private var adapter: AiHistoryAdapter? = null
    override fun initView() {
        mViewModel?.context = this
        mViewModel?.initDB(this)
        mViewModel?.getAiHistoryList()
        adapter = AiHistoryAdapter(mViewModel!!)
        mViewDataBinding?.rvHistory?.adapter = adapter
        mViewDataBinding?.rvHistory?.layoutManager = LinearLayoutManager(this)
        mViewDataBinding?.rvHistory?.addItemDecoration(SpacesItemButtonDecoration(50))

        mViewModel?.historyList?.observe(this) {
            adapter?.setListData(it.reversed())
        }
    }
}